# Euler Problem 10
# What is the sum of all primes below 2 000 000?
primemax = 2000000
primemax = 2000000

import math
#################################
cycles = 50000
cycles = 1
import time
c1 = time.clock()
#for x in xrange(0xFFFFF): pass
for i in range(cycles):
    answer = 0
#################################
### program calculation start ###
#################################

#    done = 0
#    while not done:

    # calculate primes up to maximum number
    checkprime = 3
    primearray = [2]
    while primearray[-1] < primemax:
        for checkfactor in primearray:
            if checkprime % checkfactor == 0:
                break
            if checkfactor**2 > checkprime:
                primearray.append(checkprime)
                break
        checkprime += 1

    for i in primearray:
        answer += i

    answer -= primearray[-1]        
    #print primearray                               
    
#################################
###  program calculation end  ###
#################################
c2 = time.clock()
if cycles > 1: print "Time spent is %.2f ms" % ((c2-c1)*1000/cycles)
#################################
        
print 'The answer to Problem #10 is >>', answer, '<<'

        